<template>
  <div class="roadhome">
    <div class="roadhomemain">
      <!-- 三维cesium底图 -->
      <div class="cesiumdiv">
        <cesium />
      </div>

      <!-- data 阴影 -->
      <dataShadow :backtype.sync="dataShadow" />

      <!-- header 内容 -->
      <dataHeaderBack :backtype.sync="dataHeaderBack">
        <roadheader :title="title" />
      </dataHeaderBack>

      <!-- content 边框 -->
      <dataContentBack :backtype.sync="dataContentBack" />

      <!-- content 路由内容 -->
      <div class="roadhomerv">
        <router-view />
      </div>

      <!-- 底部按钮 -->
      <div class="routerbtn">
        <div
          v-for="item in btnlist"
          :class=" item.name == activename ? 'eachbtna' : 'eachbtn'"
          @click="btnclick(item)"
        >
          <icon-svg
            :icon-class="item.icon"
            :color="item.name == activename ? '#F0971F' : '#09B1E6'"
            width="30px"
            height="30px"
          ></icon-svg>
        </div>
      </div>

      <!-- <div class="backmap">
        <backmap/>
      </div>-->
    </div>
    <el-dialog
      title="修改json"
      :visible.sync="isshowdia"
      width="50%"
      @close="isshowdia = false">
      <el-input
  type="textarea"
  :rows="20"
  placeholder="请输入内容"
  v-model="setting">
</el-input>
      <span slot="footer">
        <el-button @click="isshowdia = false">取 消</el-button>
        <el-button type="primary" @click="diaclick()">确 定</el-button>
      </span>
    </el-dialog>
    
  </div>
</template>
<script>


import roadheader from "./roadhomeheader";
import cesium from "./cesium";
import dataShadow from "./components/dataShadow";
import dataHeaderBack from "./components/dataHeaderBack";
import dataContentBack from "./components/dataContentBack";

import setting from './setting.json'
import setting1 from './setting1.json'

export default {
  components: {
    roadheader,
    cesium,
    dataShadow,
    dataHeaderBack,
    dataContentBack
  },
  data() {
    return {
      //home动态元素相关

      isshowdia: false,

      dataHeaderBack: "",
      dataShadow: "",
      dataContentBack: "",
      title: "",

      activename: "",
      btnlist: [
        { name: "aaa1", icon: "qiche" },
        { name: "aaa2", icon: "jinggai" },
        { name: "aaa3", icon: "jietouzuoyi" },
        { name: "aaa4", icon: "shebeizhuangtai" }
      ],
      setting: {
      }
    };
  },
  computed: {},
  watch: {},
  mounted() {
    this.$store.state.app.dataSetting = setting
    this.setting = JSON.stringify(this.$store.state.app.dataSetting, null, 4)


    this.loadData();
  },
  methods: {

    diaclick(){
      this.isshowdia = false
      this.$store.state.app.dataSetting = JSON.parse(this.setting)
      this.loadData()
    },

    loadData() {
      let setting = setting
      this.$store.state.dataSettingFlag++
      this.dataHeaderBack = this.$store.state.app.dataSetting.dataHeaderBack
      this.dataShadow = this.$store.state.app.dataSetting.dataShadow
      this.dataContentBack = this.$store.state.app.dataSetting.dataContentBack
      this.title = this.$store.state.app.dataSetting.detail.title.titleMiddle.element[0].name;

    },
    btnclick(item) {
      this.activename = item.name;
      switch (item.name) {
        case "aaa4":
          this.$router.push("/");
          break;
        case "aaa1":
          this.isshowdia = true
          break;
        case "aaa2":
          this.$store.state.app.dataSetting = setting
          this.loadData()
          break;
        case "aaa3":
          this.$store.state.app.dataSetting = setting1
          this.loadData()

          break;

        default:
          break;
      }
    }
  }
};
</script>
<style lang='scss' scoped>
.roadhome {

  .cesiumdiv {
    z-index: 1;
    height: 100vh;
  }

  .roadhomerv {
    position: absolute;
    pointer-events: none;
    top: 94px;
    z-index: 10;
  }
  
  .routerbtn {
    position: absolute;
    margin: 0 auto;
    width: 400px;
    height: 50px;
    color: aqua;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: row;
    z-index: 9;
    justify-content: space-between;
    .eachbtna {
      width: 41px;
      height: 41px;
      background: url();
      background-repeat: no-repeat;
      // text-align: center;
      display: flex;
      flex: row;
      justify-content: center;
      align-items: center;
      cursor: pointer;
    }
    .eachbtn {
      width: 41px;
      height: 41px;
      background: url();
      background-repeat: no-repeat;
      // text-align: center;
      display: flex;
      flex: row;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      &:hover {
        width: 41px;
        height: 41px;
        background: url();
        background-repeat: no-repeat;
      }
    }
  }
}
</style>